import * as THREE from 'three';
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
import mesh from './customMesh.js';

const scene = new THREE.Scene();

scene.add(mesh);
const pointLight = new THREE.PointLight(0xffffff, 1, 100);
pointLight.position.set(200, 200, 200);
scene.add(pointLight);

const axeshelper = new THREE.AxesHelper(200);
scene.add(axeshelper);

const width = window.innerWidth;
const height = window.innerHeight;
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
camera.position.set(200, 200, 200);
camera.lookAt(0, 0, 0);

const renderer = new THREE.WebGLRenderer();
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);
renderer.render(scene, camera);
const animate = function () {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
};
animate();

//轨道控制器
const controls = new OrbitControls(camera, renderer.domElement);
controls.addEventListener("change", function () {
    renderer.render(scene, camera);
});


